package com.dhcc.bpm.business.papc.service.impl;

//import com.baomidou.dynamic.datasource.annotation.DS;
import com.dhcc.bpm.business.papc.entity.ErrcodeMap;
import com.dhcc.bpm.business.papc.vo.ErrcodeMapVO;
import com.dhcc.bpm.business.papc.mapper.ErrcodeMapMapper;
import com.dhcc.bpm.business.papc.service.IErrcodeMapService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.util.StringUtils;
import java.util.List;

/**
 * 错误码映射表  服务实现类
 *
 * @author liuzhao
 * @since 2020-05-16
 */
@Service
//@DS("slave")
public class ErrcodeMapServiceImpl extends BaseServiceImpl<ErrcodeMapMapper, ErrcodeMap> implements IErrcodeMapService {

    @Override
    public IPage<ErrcodeMapVO> selectErrcodeMapPage(IPage<ErrcodeMapVO> page, ErrcodeMapVO errcodeMap) {
        return page.setRecords(baseMapper.selectErrcodeMapPage(page, errcodeMap));
    }

    @Override
    public ErrcodeMap selectErrcodeMapById(Long id) {
        return baseMapper.selectErrcodeMapById(id);
    }

    @Override
    public boolean saveOrUpdate(ErrcodeMap errcodeMap) {
        int result;
        if (StringUtils.isEmpty(errcodeMap.getId())) {
            result = baseMapper.save(errcodeMap);
        } else {
            errcodeMap.setErrcodeMapKey(errcodeMap.getId().toString());
            result = baseMapper.update(errcodeMap);
        }
        return result >= 1;
    }

    @Override
    public boolean deleteErrcodeMapByIds(String ids) {
        int result = baseMapper.deleteErrcodeMapByIds(ids.split(","));
        return result >= 1;
    }

    @Override
    public List<ErrcodeMap> selectErrcodeMapAll(ErrcodeMap errcodeMap) {
        return baseMapper.selectErrcodeMapAll(errcodeMap);
    }
}
